import { loadEnv } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'path'
// import viteCompression from 'vite-plugin-compression';
import uniReadPagesV3Plugin from './sheep/router/utils/uni-read-pages-v3'

export default (command, mode) => {
  const env = loadEnv(mode, __dirname, 'MES_')
  return {
    envPrefix: 'MES_',
    plugins: [
      uni(),
      // viteCompression({
      // 	verbose: false
      // }),
      uniReadPagesV3Plugin({
        pagesJsonDir: path.resolve(__dirname, './pages.json'),
        includes: ['path', 'aliasPath', 'name', 'meta']
      })
      // mpliveMainfestPlugin(env.MES_MPLIVE_ON)
    ],
    server: {
      host: true,
      // open: true,
      port: env.MES_DEV_PORT,
      hmr: {
        overlay: true
      }
    }
  }
}
